#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>

bool prost(int c) {
    if (c == 1) {
        return false;
    }
    for (int i = 2; i <= static_cast<int>(std::sqrt(c)); ++i) {
        if (c % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    std::string input;
    std::getline(std::cin, input);
    std::istringstream iss(input);
    std::vector<std::string> a;
    std::string word;
    while (iss >> word) {
        a.push_back(word);
    }

    std::string c = "";
    if (a.size() == 3 &&
        (a[0] == "zero" || a[0] == "one" || a[0] == "two" || a[0] == "three" || a[0] == "four" || a[0] == "five" || a[0] == "six" || a[0] == "seven" || a[0] == "eight" || a[0] == "nine") &&
        (a[1] == "zero" || a[1] == "one" || a[1] == "two" || a[1] == "three" || a[1] == "four" || a[1] == "five" || a[1] == "six" || a[1] == "seven" || a[1] == "eight" || a[1] == "nine") &&
        (a[2] == "zero" || a[2] == "one" || a[2] == "two" || a[2] == "three" || a[2] == "four" || a[2] == "five" || a[2] == "six" || a[2] == "seven" || a[2] == "eight" || a[2] == "nine")) {

        std::vector<std::string> numbers = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 10; ++j) {
                if (a[i] == numbers[j]) {
                    c += std::to_string(j);
                    break;
                }
            }
        }

        int c_int = std::stoi(c);
        int c2 = c_int;

        int d1 = 0;
        int d2 = 0;
        bool e = false;

        while (!e) {
            e = prost(c_int);
            if (!e) {
                d1++;
                c_int--;
            }
        }

        e = false;
        while (!e) {
            e = prost(c2);
            if (!e) {
                d2++;
                c2++;
            }
        }

        if (d1 > d2) {
            std::cout << c2 << std::endl;
        } else if (d2 > d1) {
            std::cout << c_int << std::endl;
        } else {
            std::cout << c_int << std::endl;
        }
    } else {
        std::cout << "wrong input" << std::endl;
    }

    return 0;
}
